package tms;

import java.util.List;
import java.util.Observable;
import java.util.Observer;

import tms.model.Account;
import tms.model.Destination;

public class Cache {

//  public static Account CURRENT_USER = Account.getFirstDynamic("email = 'admin@admin.com'");
    public static Account currentUser = null;
    public static List<Destination> allDestinations = null;

    /**
     * Please use this method to set current user after login.
     * The static CURRENT_USER is just for reference the value
     * @param user
     */
    public static void setCurrentUser(Account user) {
        currentUser = user;
        observable.notifyObservers(user);
    }

    private static Observable observable = new Observable() {
        @Override
        public void notifyObservers(Object obj) {
            setChanged();
            super.notifyObservers(obj);
        }
    };

    public static void addObserver(Observer o) {
        observable.addObserver(o);
    }

}
